package com.jrx.anytxn.transaction.service;

import com.jrx.anytxn.common.exception.TxnBizException;
import com.jrx.anytxn.common.exception.TxnException;
import com.jrx.anytxn.transaction.bean.PaymentSaveBean;
import com.jrx.anytxn.transaction.entity.*;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 *  还款分配service
 *
 * @author : xiaoyu.jing
 * date: 2019-10-15 00:22
 **/
public interface IDealPaymentService {
    /**
     * 逾期还款还款分配
     * @param paymentLog 还款流水
     * @param loanMainInfoList 贷款订单列表
     * @param bussinessDate 业务日期
     * @throws TxnException 自定义业务异常
     */
    void dealOverPay(TlPaymentLog paymentLog, List<AmLoanMainInfo> loanMainInfoList, Date bussinessDate) throws TxnException;

    /**
     * 逾期还款计算 试算计算分配金额
     * @param loanMainInfoList 贷款订单列表
     * @param loanAccountInfos 贷款订单账户列表
     * @param businessDate 业务日期
     * @param repayAmt 还款金额
     *
     * @throws TxnException 自定义业务异常
     */
    List<TlPaymentAllocationLog> calculationOverPay(List<AmLoanMainInfo> loanMainInfoList,List<AmLoanAccountInfo> loanAccountInfos, Date businessDate, BigDecimal repayAmt) throws TxnBizException;

    /**
     * 提前结清还款分配
     * @param paymentLog 还款流水
     * @param loanMainInfoList 贷款订单列表
     * @param bussinessDate 业务日期
     * @throws TxnException 自定义业务异常
     */
    void dealPayOff(TlPaymentLog paymentLog, List<AmLoanMainInfo> loanMainInfoList, Date bussinessDate) throws TxnException;

    /**
     * 提前还款还款分配
     * @param paymentLog 还款流水
     * @param loanMainInfo 贷款订单信息
     * @param bussinessDate 业务日期
     * @throws TxnException 自定义业务异常
     */
    void dealPrePay(TlPaymentLog paymentLog, AmLoanMainInfo loanMainInfo, Date bussinessDate) throws TxnException;

    /**
     * 提前还款费用计算
     * @param loanAccountInfo 贷款账户信息
     * @param loanMainInfo 贷款订单信息
     * @param businessDate 业务日期
     * @param repayAmt 还款金额
     *
     * @throws TxnException 自定义业务异常
     */
    List<TlPaymentAllocationLog> calculationPrePay(AmLoanAccountInfo loanAccountInfo, AmLoanMainInfo loanMainInfo,
                                                   Date businessDate, BigDecimal repayAmt) throws TxnException;

    /**
     * 正常还款还款分配
     * @param paymentLog 还款流水
     * @param loanMainInfos 贷款订单列表
     * @param bussinessDate 业务日期
     * @throws TxnException 自定义业务异常
     */
    void dealPay(TlPaymentLog paymentLog, List<AmLoanMainInfo> loanMainInfos, Date bussinessDate) throws TxnException;

    /**
     * 代偿还款分配
     * @param paymentLog 还款流水
     * @param loanMainInfoList 贷款订单列表
     * @param bussinessDate 业务日期
     * @throws TxnException 自定义业务异常
     */
    void dealCmpsPay(TlPaymentLog paymentLog, List<AmLoanMainInfo> loanMainInfoList, Date bussinessDate) throws TxnException;

    /**
     * 回购还款分配
     * @param paymentLog 还款流水
     * @param loanMainInfoList 贷款订单列表
     * @param bussinessDate 业务日期
     * @throws TxnException 自定义业务异常
     */
    void dealCrtPay(TlPaymentLog paymentLog, List<AmLoanMainInfo> loanMainInfoList, Date bussinessDate) throws TxnException;

    /**
     * 账单分期分配
     * @param tlLoanStagingMappingList 账单分期关联表
     * @param bussinessDate 业务日期
     * @throws TxnException 自定义业务异常
     */
    void dealLoanStaging(List<TlLoanStagingMapping> tlLoanStagingMappingList, Date bussinessDate) throws TxnException;

    /**
     * 账单逾期还款还款分配
     * @param paymentLog
     * @param loanMainInfos
     * @param bussinessDate
     * @throws TxnException
     */
    void dealBillOverDuePay(TlPaymentLog paymentLog, List<AmLoanMainInfo> loanMainInfos, Date bussinessDate) throws TxnException;

    /**
     * 账单正常还款还款分配
     * @param paymentLog
     * @param loanMainInfos
     * @param bussinessDate
     * @throws TxnException
     */
    void dealBillPay(TlPaymentLog paymentLog, List<AmLoanMainInfo> loanMainInfos, Date bussinessDate) throws TxnException;

    /**
     * 账单提前还当期还款分配
     * @param paymentLog
     * @param loanMainInfos
     * @param bussinessDate
     * @throws TxnException
     */
    void dealBillPrepayCurr(TlPaymentLog paymentLog, List<AmLoanMainInfo> loanMainInfos, Date bussinessDate) throws TxnException;

    /**
     * 账单提前还款
     * @param tlPaymentLog
     * @param loanList
     * @param bussinessDate
     */
    void dealBillPrepay(TlPaymentLog tlPaymentLog, List<AmLoanMainInfo> loanList, Date bussinessDate) throws TxnException;

    /**
     * 账单逾期提前还当期还款分配
     * @param paymentLog
     * @param loanMainInfos
     * @param bussinessDate
     * @throws TxnException
     */
    void dealBillOverPrepayCurr(TlPaymentLog paymentLog, List<AmLoanMainInfo> loanMainInfos, Date bussinessDate) throws TxnException;


    /**
     * 逾期还款还款分配
     * @param paymentLog 还款流水
     * @param loanMainInfoList 贷款订单列表
     * @param bussinessDate 业务日期
     * @throws TxnException 自定义业务异常
     */
    PaymentSaveBean dealOverPayNotSave(TlPaymentLog paymentLog, List<AmLoanMainInfo> loanMainInfoList, Date bussinessDate) throws TxnException;

    /**
     * 提前结清还款分配
     * @param paymentLog 还款流水
     * @param loanMainInfoList 贷款订单列表
     * @param bussinessDate 业务日期
     * @throws TxnException 自定义业务异常
     */
    PaymentSaveBean dealPayOffNotSave(TlPaymentLog paymentLog, List<AmLoanMainInfo> loanMainInfoList, Date bussinessDate) throws TxnException;

    /**
     * 正常还款还款分配
     * @param paymentLog 还款流水
     * @param loanMainInfos 贷款订单列表
     * @param bussinessDate 业务日期
     * @throws TxnException 自定义业务异常
     */
    PaymentSaveBean dealPayNotSave(TlPaymentLog paymentLog, List<AmLoanMainInfo> loanMainInfos, Date bussinessDate) throws TxnException;

    /**
     * 提前还款还款分配
     * @param paymentLog
     * @param loanMainInfo
     * @param bussinessDate
     * @return
     * @throws TxnException
     */
    PaymentSaveBean dealPrePayNotSave(TlPaymentLog paymentLog, AmLoanMainInfo loanMainInfo, Date bussinessDate) throws TxnException;

    /**
     *保存还款分配信息
     * @param saveBean
     */
    void saveAllAccts(PaymentSaveBean saveBean);

    /**
     * 处理退款
     * @param tlPaymentLog
     * @param loanList
     * @param bussinessDate
     */
    void dealRefund(TlPaymentLog tlPaymentLog, List<AmLoanMainInfo> loanList, Date bussinessDate) throws TxnException;
}
